package enum_;

/**
 * 体会枚举对象的静态本质
 */
public class Test03 {
    public static void main(String[] args) {
       Gender girl  =  Gender.GIRL;//等价于 static final Gender girl = new Gender("GIRL");
       Gender girl2 =  Gender.GIRL;
       Gender boy =  Gender.BOY;//等价于 static final Gender boy = new Gender("BOY");
       System.out.println(girl);//GIRL
       System.out.println(girl2);//GIRL
       //因为是静态的对象，同一个类，所有实例共享 ，所以地址当然是一样的
       System.out.println(girl == girl2);//true
       //两个不同的new实例
        System.out.println(boy == girl);//false
    }
}
enum Gender {
    BOY,GIRL
}
